﻿using System;
using System.Collections.Generic;
using System.Text;
using DAL.DateSet.ModifyRecordTableAdapters;
using DAL.DateSet;
using DAL;
namespace BLL.Wrapper
{
    public class ModifyRecordWrapper : ModifyRecordTableAdapter
    {
        public ModifyRecord.ModifyRecordDataTable getall()
        {
            return GetData();
        }

        public void addARecord(ModifyRecord.ModifyRecordRow row)
        {
            Insert(row.modifyTable, row.itemID, row.modifyPerson, row.modifyTime, row.modifyDetail);
        }

        public void deleteByID(int id)
        {
            string sql = "delete from ModifyRecord where modifyID = " + id.ToString();
            HouseDiyHelper helper = HouseDiyHelper.GetInstance();
            helper.initOle();
            helper.delete(sql);
        }

        public void updateARecord(ModifyRecord.ModifyRecordRow row)
        {
            ModifyRecord.ModifyRecordDataTable table = GetData();
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (Convert.ToInt32(table.Rows[i]["modifyID"]) == row.modifyID)
                {
                    table.Rows[i]["modifyTable"] = row.modifyTable;
                    table.Rows[i]["itemID"] = row.itemID;
                    table.Rows[i]["modifyPerson"] = row.modifyPerson;
                    table.Rows[i]["modifyTime"] = row.modifyTime;

                    table.Rows[i]["modifyDetail"] = row.modifyDetail;
                    break;
                }
            }
            Update(table);
        }
    }
}
